//
//  ZHCache.m
//  ZH_Helper
//
//  Created by caixiang on 2017/10/18.
//  Copyright © 2017年 蔡翔. All rights reserved.
//

#import "ZHCacheHelper.h"
#import "YYCache.h"

static NSString *const kZHResponseCache = @"kZHResponseCache";

@implementation ZHCacheHelper
static YYCache *_dataCache;

+ (void)initialize {
    _dataCache = [YYCache cacheWithName:kZHResponseCache];
}

+ (void)zh_setObject:(id)object key:(NSString *)key {
    [_dataCache setObject:object forKey:key withBlock:nil];
}

+ (void)zh_setObject:(id)object key:(NSString *)key withBlock:(void (^)(void))block {
    [_dataCache setObject:object forKey:key withBlock:block];
}

+ (id)zh_objectForKey:(NSString *)key {
    return [_dataCache objectForKey:key];
}

+ (void)zh_objectForKey:(NSString *)key withBlock:(void (^)(NSString *key, id<NSCoding> object))block {
    [_dataCache objectForKey:key withBlock:block];
}

+ (void)zh_removeObjectForKey:(NSString *)key {
    [_dataCache removeObjectForKey:key];
}

+ (void)zh_removeObjectForKey:(NSString *)key withBlock:(void (^)(NSString *key))block {
    [_dataCache removeObjectForKey:key withBlock:block];
}

+ (void)zh_removeAllObjects {
    [_dataCache removeAllObjects];
}

@end
